#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

int a[1000000], n, m, k = 0;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++)cin >> a[k++];
    cin >> m;
    for (int i = 0; i < m; i++)cin >> a[k++];
    inplace_merge(a, a + n, a + k);//原地合并两个有序的数组
    copy(a, a + k, ostream_iterator<int>(cout, " "));

    return 0;
}
